import { Message } from 'element-ui'
import router from '../router/index'
import {getToken} from './token'
router.beforeEach((to,from,next)=>{
  if(to.name==='login'||to.name==='home'||to.name==='search'||to.name==='item') {
    next()
    return
  }
  if((to.name==='chat'|| to.name==='my'|| to.name==='car'||to.name==='myInfo')&& getToken()){
    next()
  }else{
    next('login')
    Message.error('请先登录')
  }
})
